﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QLabel>
#include <QSpinBox>
#include <QTreeWidgetItem>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void on_actAddFolder_triggered();

    void on_m_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);

    void on_actAddFiles_triggered();

    void on_actZoomIn_triggered();

    void on_actZoomOut_triggered();

    void on_actZoomRealSize_triggered();

    void on_actZoomFitW_triggered();

    void on_actZoomFitH_triggered();

    void on_actDeleteItem_triggered();

    void on_actScanItems_triggered();

    void on_dockWidget_visibilityChanged(bool visible);

    void on_dockWidget_topLevelChanged(bool topLevel);

    void on_actDockVisable_triggered(bool checked);

    void on_actDockFloat_triggered(bool checked);

    void on_m_treeWidget_itemChanged(QTreeWidgetItem *item, int column);

private:
    //itTopItem 顶层节点;  itGroupItem 组节点； itImageItem 图片
    enum    treeItemType{itTopItem=1001,itGroupItem,itImageItem};

    //枚举类型，表示列号
    enum    treeColNum{colItem=0, colItemType=1, colDate}; //目录树列的编号定义

    void addFolderItem(QTreeWidgetItem* paritem, QString DirName);
    QString getRealFolderName(QString DirName);
    void addImageItem(QTreeWidgetItem* paritem, QString aFileName);
    void displayImage(QTreeWidgetItem* current);
    void delItem(QTreeWidgetItem* parItem,QTreeWidgetItem* item);
    void changeItemCaption(QTreeWidgetItem* item);
private:
    void initStatusBar();
    void initTreeHeader();
    void initTree();

private:
    Ui::MainWindow *ui;
    QLabel* m_labNodeText;
    QSpinBox * m_spinRatio;
    QLabel* m_labFileName;

    QPixmap m_pixmap; //当前的图片
    float   m_ratio;//当前图片缩放比例
};
#endif // MAINWINDOW_H
